﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UFIDA.U9.AP.Enums;
using UFIDA.U9.CBO.FI.Enums;
using UFIDA.U9.CBO.SCM.Item;
using UFSoft.UBF.Business;
using UFSoft.UBF.Eventing;

namespace UFIDA.U9.CusDev.QJKJPlugInBE
{
    class ProcessForARBillItem : IEventSubscriber
    {
        public void Notify(params object[] args)
        {

            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent)) return;
            BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;

            if (key == null || key.GetEntity() == null) return;
            //应收单
            UFIDA.U9.AR.ARBill.ARBillHead ar = key.GetEntity() as UFIDA.U9.AR.ARBill.ARBillHead;
            if (ar == null) return;

            #region 应收单新增时，当料品不为空时，将料品私有字段3税收分类值，写入应收单行私有字段5

            foreach (var line in ar.ARBillLines)
            {
                if (line.Item.ItemID == null)
                {
                    return;
                }
                else
                {
                    ItemMaster itemMaster = line.Item.ItemID;
                    if (line.DescFlexField.PrivateDescSeg5 == "" || line.DescFlexField.PrivateDescSeg5 == null)
                    {
                        line.DescFlexField.PrivateDescSeg5 = itemMaster.DescFlexField.PrivateDescSeg3;
                    }
                }
               
                

            }

            #endregion

        }

    }
}
